

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>NFS &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="分布式文件系统之上的应用程序最佳实践" href="../app-best-practices/" />
    <link rel="prev" title="ceph-mds -- Ceph 元数据服务器守护进程" href="../../man/8/ceph-mds/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 文件系统</a></li>
      <li class="breadcrumb-item active">NFS</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/cephfs/nfs.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id4">管理</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../createfs/"> 创建 CephFS 文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../administration/"> 管理命令</a></li>
<li class="toctree-l3"><a class="reference internal" href="../multifs/"> 创建多个文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../add-remove-mds/"> 配备、增加、删除 MDS</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/">术语</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds">MDS 守护进程的引用</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#id3">故障切换的管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#standby-replay">热备（ standby-replay ）的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds-join-fs">配置 MDS 与文件系统的亲和性</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cache-configuration/"> MDS 缓存配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mds-config-ref/"> MDS 配置选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../man/8/ceph-mds/"> ceph-mds 手册页</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> 通过 NFS 导出</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">必要条件</a></li>
<li class="toctree-l4"><a class="reference internal" href="#nfs-ganesha-cephfs">配置 NFS-Ganesha 来导出 CephFS</a></li>
<li class="toctree-l4"><a class="reference internal" href="#nfsv4">用 NFSv4 客户端挂载</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../app-best-practices/"> 应用最佳实践</a></li>
<li class="toctree-l3"><a class="reference internal" href="../fs-volumes/"> FS 卷和子卷</a></li>
<li class="toctree-l3"><a class="reference internal" href="../quota/"> CephFS 配额管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../health-messages/"> 健康消息</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/">升级 MDS 集群</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/#firefly-jewel">升级比 Firefly 老的文件系统，需过 Jewel 这个槛</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-top/"> CephFS Top 工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../snap-schedule/"> 定时快照</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-mirroring/"> CephFS 快照镜像</a></li>
<li class="toctree-l3"><a class="reference internal" href="../purge-queue/"> 清理队列</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id6">CephFS 内幕</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="nfs">
<span id="cephfs-nfs"></span><h1>NFS<a class="headerlink" href="#nfs" title="Permalink to this heading"></a></h1>
<p>CephFS 命名空间可以通过 NFS 协议导出，用 <a class="reference external" href="https://github.com/nfs-ganesha/nfs-ganesha/wiki">NFS-Ganesha NFS 服务器</a> 。本文档说的是
NFS-Ganesha 集群的手动配置方法。最简单的、首选的方法是通过 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">nfs</span> <span class="pre">...</span></code> 系列命令来管理 NFS-Ganesha 集群和 CephFS 的导出。详情见 <a class="reference internal" href="../../mgr/nfs/"><span class="doc">CephFS &amp; RGW Exports over NFS</span></a> 。
假设 Ceph 是用 cephadm 或 rook 部署的。</p>
<section id="id1">
<h2>必要条件<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<ul class="simple">
<li><p>Ceph 文件系统</p></li>
<li><p>在 NFS 服务器所在主机上有 <code class="docutils literal notranslate"><span class="pre">libcephfs2</span></code> 、 <code class="docutils literal notranslate"><span class="pre">nfs-ganesha</span></code>
和 <code class="docutils literal notranslate"><span class="pre">nfs-ganesha-ceph</span></code> 软件包。</p></li>
<li><p>连接到 Ceph 公共网的 NFS-Ganesha 服务器主机。</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>建议用 3.5 或更高稳定版的 NFS-Ganesha 软件包，
对接 pacific (16.2.x) 或更高版本的 Ceph 。</p>
</div>
</section>
<section id="nfs-ganesha-cephfs">
<h2>配置 NFS-Ganesha 来导出 CephFS<a class="headerlink" href="#nfs-ganesha-cephfs" title="Permalink to this heading"></a></h2>
<p>NFS-Ganesha 有一个文件系统抽象层（ File System Abstraction Layer, FSAL ）来适配不同的存储后端。 <a class="reference external" href="https://github.com/nfs-ganesha/nfs-ganesha/tree/next/src/FSAL/FSAL_CEPH">FSAL_CEPH</a> 是适配 CephFS 的 FSAL 插件。对于每一个 NFS-Ganesha 导出，
<a class="reference external" href="https://github.com/nfs-ganesha/nfs-ganesha/tree/next/src/FSAL/FSAL_CEPH">FSAL_CEPH</a> 都会用一个 libcephfs 客户端来挂载 NFS-Ganesha 要导出的 CephFS 路径。</p>
<p>对接 NFS-Ganesha 和 CephFS 的配置，涉及 NFS-Ganesha 的配置、 Ceph 配置文件、
NFS-Ganesha 创建的、用于访问 CephFS 的客户端所需的 CephX 访问证书。</p>
<section id="nfs-ganesha">
<h3>NFS-Ganesha 配置<a class="headerlink" href="#nfs-ganesha" title="Permalink to this heading"></a></h3>
<p>这里有个用 <a class="reference external" href="https://github.com/nfs-ganesha/nfs-ganesha/tree/next/src/FSAL/FSAL_CEPH">FSAL_CEPH</a> 配置的 <a class="reference external" href="https://github.com/nfs-ganesha/nfs-ganesha/blob/next/src/config_samples/ceph.conf">ganesha.conf 样本</a> 。
它适合独立的 NFS-Ganesha 服务器，或者主从式的 NFS-Ganesha 服务器，
这样适合让某些集群化软件管理（如 Pacemaker ）。
关于选项的重要信息在样板配置的注释里。其中有些选项是：</p>
<ul class="simple">
<li><p>尽可能最小化 Ganesha 的缓存，因为 <a class="reference external" href="https://github.com/nfs-ganesha/nfs-ganesha/tree/next/src/FSAL/FSAL_CEPH">FSAL_CEPH</a> 的 libcephfs 客户端也会激进地缓存；</p></li>
<li><p>从 Ganesha 配置文件里读出，它存储在 RADOS 对象里；</p></li>
<li><p>用 RADOS OMAP 的键值接口存储客户端的恢复数据；</p></li>
<li><p>指明访问协议为 NFSv4.1+</p></li>
<li><p>启用读取授权（需要最低 v13.0.1 版的 <code class="docutils literal notranslate"><span class="pre">libcephfs2</span></code> 软件包和
v2.6.0 稳定版的 <code class="docutils literal notranslate"><span class="pre">nfs-ganesha</span></code> 和 <code class="docutils literal notranslate"><span class="pre">nfs-ganesha-ceph</span></code> 软件包）</p></li>
</ul>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>在某些情况下，使用 CephFS FSAL 的 NFS 访问会失败。
这会导致抛出 “Input/output error” （输入/输出错误）错误信息。
在这种情况下，必须给 CephFS 元数据和数据存储池设置应用程序元数据。
运行以下命令进行设置：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "$ ";
}
</style><span class="prompt1">ceph<span class="w"> </span>osd<span class="w"> </span>pool<span class="w"> </span>application<span class="w"> </span><span class="nb">set</span><span class="w"> </span>&lt;cephfs_metadata_pool&gt;<span class="w"> </span>cephfs<span class="w"> </span>&lt;cephfs_data_pool&gt;<span class="w"> </span>cephfs</span>
</pre></div></div></div>
</section>
<section id="libcephfs">
<h3>给 libcephfs 客户端的配置<a class="headerlink" href="#libcephfs" title="Permalink to this heading"></a></h3>
<p>libcephfs 客户端的 <code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code> 包含一个 <code class="docutils literal notranslate"><span class="pre">[client]</span></code> 段，要设置其下的 <code class="docutils literal notranslate"><span class="pre">mon_host</span></code> 选项，
客户端才能连接到集群的监视器，通常是用 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">config</span> <span class="pre">generate-minimal-conf</span></code> 命令生成的。
例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">client</span><span class="p">]</span>
        <span class="n">mon</span> <span class="n">host</span> <span class="o">=</span> <span class="p">[</span><span class="n">v2</span><span class="p">:</span><span class="mf">192.168.1.7</span><span class="p">:</span><span class="mi">3300</span><span class="p">,</span><span class="n">v1</span><span class="p">:</span><span class="mf">192.168.1.7</span><span class="p">:</span><span class="mi">6789</span><span class="p">],</span> <span class="p">[</span><span class="n">v2</span><span class="p">:</span><span class="mf">192.168.1.8</span><span class="p">:</span><span class="mi">3300</span><span class="p">,</span><span class="n">v1</span><span class="p">:</span><span class="mf">192.168.1.8</span><span class="p">:</span><span class="mi">6789</span><span class="p">],</span> <span class="p">[</span><span class="n">v2</span><span class="p">:</span><span class="mf">192.168.1.9</span><span class="p">:</span><span class="mi">3300</span><span class="p">,</span><span class="n">v1</span><span class="p">:</span><span class="mf">192.168.1.9</span><span class="p">:</span><span class="mi">6789</span><span class="p">]</span>
</pre></div>
</div>
</section>
</section>
<section id="nfsv4">
<h2>用 NFSv4 客户端挂载<a class="headerlink" href="#nfsv4" title="Permalink to this heading"></a></h2>
<p>最好用 NFSv4.1+ 协议挂载 NFS-Ganesha 的出口，这样才能获得会话上的好处。</p>
<p>挂载 NFS 资源的惯例因平台而变，下面的惯例适合 Linux 和某些 Unix 平台：</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>mount<span class="w"> </span>-t<span class="w"> </span>nfs<span class="w"> </span>-o<span class="w"> </span><span class="nv">nfsvers</span><span class="o">=</span><span class="m">4</span>.1,proto<span class="o">=</span>tcp<span class="w"> </span>&lt;ganesha-host-name&gt;:&lt;ganesha-pseudo-path&gt;<span class="w"> </span>&lt;mount-point&gt;
</pre></div>
</div>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../../man/8/ceph-mds/" class="btn btn-neutral float-left" title="ceph-mds -- Ceph 元数据服务器守护进程" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../app-best-practices/" class="btn btn-neutral float-right" title="分布式文件系统之上的应用程序最佳实践" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>